//获取引用试题列表
flushTable('http://139.199.200.112/dtpr/index.php?exam-teach-questions-quotelist',JSON.stringify({"page":1}),".page-set","#set tbody")

//引用试题
function reference() {
    var id=getTdId(this);

    if(!confirm("你确定要引用这套题吗")){
        return;
    }

    $.get("http://139.199.200.112/dtpr/index.php?exam-teach-questions-quote",{"id":id},function (data) {
        var data=JSON.parse(data);

        if(data.code==0){
            alert("引用成功");
        }else {
            alert(data.msg);
        }
    })
}

//生成一行的set
function addLine(data,url) {
    if(url==="http://139.199.200.112/dtpr/index.php?exam-teach-questions-quotelist"){
        var tbody=$("#set").find("tbody");
        var line=$("<tr>\n" +
            "    <td>"+data.id+"</td>\n" +
            "    <td><a data-toggle='modal' data-target='#show-test'>"+data.exam+"</a></td>\n" +
            "    <td>"+data.subject+"</td>\n" +
            "    <td>"+data.volume+"</td>\n" +
            "    <td>"+data.section+"</td>\n" +
            "    <td>"+data.author+"</td>\n" +
            "    <td><button class='btn btn-primary'>引用</button></td>\n" +
            "</tr>");

        line.find(".btn").click(reference);
        line.find("a").click(openDetail);

        tbody.append(line);
    }else {
        var tbody=$("#show-test").find("tbody");
        var line=$("<tr>\n" +
            "    <td>"+data.subject+"</td>\n" +
            "    <td>"+data.volume+"</td>\n" +
            "    <td>"+data.section+"</td>\n" +
            "    <td>"+data.question+"</td>\n" +
            questionLevel[data.level-1]+
            "</tr>");

        tbody.append(line);
    }
}

//查看题集的详细内容
function openDetail() {
    var bodyEle="#show-test tbody";
    var pageEle="#show-test .page-detail";
    var url="http://139.199.200.112/dtpr/index.php?exam-teach-questions-quoteinfo";
    var json={"id":$($(this).parents("tr").find("td")[0]).text(),"page":1};

    console.log(json);

    flushTable(url,JSON.stringify(json),pageEle,bodyEle);
}